#ifndef _TEST_APP
#define _TEST_APP
#include "ofMain.h"
#include "ofxVectorMath.h"
#include "ofxOsc.h"
#include "fft.h"

// listen on port 1236
#define PORT 1236
#define NUM_MSG_STRINGS 20
#define MAXUSERS 8
#define CTIME 20

#define BUFFER_SIZE 256
#define NUM_WINDOWS 80

#define MODE_RODA 0
#define MODE_SOLITUDE 1

#define T_TIME 50000 // 50 seconds

struct bola
{
	ofPoint pt;
	int size;
};



// -------------------------------------------------

class testApp : public ofBaseApp {
	
public:
	
	testApp();
	void setup();
	void update();
	void draw();
	
	void keyPressed(int key);
	void keyReleased(int key);
	void mouseMoved(int x, int y);
	void mouseDragged(int x, int y, int button);
	void mousePressed(int x, int y, int button);
	void mouseReleased(int x, int y, int button);
	void resized(int w, int h);
	void choosecolor(int j);
	void audioReceived 	(float * input, int bufferSize, int nChannels); 
	
	float px, py;
	int size;
	int user;
	bool allUsers, camOn;
	int Turnsize;
	int audioinc;

	vector		<bola>	boles[MAXUSERS];  //	this is a custom particle the extends a cirlce
	int count[MAXUSERS]; 

//	ofVideoGrabber 		vidGrabber;
	int 				camWidth;
	int 				camHeight;

	ofxOscReceiver	receiver;

	private:	
		float * left;
		float * right;
		int 	bufferCounter;
		fft		myfft;
		
		float magnitude[BUFFER_SIZE];
		float phase[BUFFER_SIZE];
		float power[BUFFER_SIZE];

		float tot_magnitude[MAXUSERS];
		
		float freq[NUM_WINDOWS][BUFFER_SIZE/2];
		float freq_phase[NUM_WINDOWS][BUFFER_SIZE/2];

		int global_mode;

		int time[MAXUSERS];
//		float volume[MAXUSERS];
		float volume_amo[MAXUSERS];

		int time_amo;

		int time_old;
};

#endif
